//
//  M_MineChongZhiViewController.m
//  Model
//
//  Created by apple on 2018/7/10.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "M_MineChongZhiViewController.h"
#import "M_MineChoneZhiTableViewCell.h"
@interface M_MineChongZhiViewController ()<UITableViewDelegate, UITableViewDataSource>
{
     UIView *vipView;//弹窗
}
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArr;



@end

@implementation M_MineChongZhiViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:NO];

}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"充值服务";
    self.view.backgroundColor = getColor(@"f8f8f8");
    [self creationview];
    [self regeditCell];
    // Do any additional setup after loading the view.
}
- (void)creationview{

    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT-64);
    
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = getColor(@"f8f8f8");
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
}
- (void)regeditCell{
    
    [self.tableView registerNib:[UINib nibWithNibName:@"M_MineChoneZhiTableViewCell" bundle:nil] forCellReuseIdentifier:@"M_MineChoneZhiTableViewCell"];
    
}
#pragma mark - ---------- Section的数量 ----------
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

#pragma mark - ---------- 每个Section的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    
    return 0;
}

#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
    
    
}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 70;
  
}
#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    M_MineChoneZhiTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"M_MineChoneZhiTableViewCell" forIndexPath:indexPath];

    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
        
 
}

#pragma mark - ---------- 每个Cell的点击事件 ----------
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    vipView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT)];
    vipView.backgroundColor = [UIColor colorWithRed:0 / 255.0f green:0 / 255.0f blue:0 / 255.0f alpha:0.2];
    
    [[UIApplication sharedApplication].keyWindow addSubview:vipView];
    
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissVIPView)];
    [vipView addGestureRecognizer:tapGesture];
    UIView *bangView = [[UIView alloc] init];
    [vipView addSubview:bangView];
    [bangView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).with.offset((KIsiPhoneX?24:0)+180);
        make.height.offset(235);
        make.left.equalTo(self.view).with.offset(24);
        make.right.equalTo(self.view).with.offset(-24);
        
    }];
    bangView.backgroundColor = [UIColor whiteColor];
    bangView.layer.cornerRadius = 5;
    UILabel *moneyLab = [[UILabel alloc] init];
    [bangView addSubview:moneyLab];
    [moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bangView).with.offset(50);
        make.centerX.equalTo(bangView);
        
    }];
    moneyLab.text = @"账户余额: 1111111";
    moneyLab.textColor = getColor(@"ff40c6");
    moneyLab.font = [UIFont systemFontOfSize:17];
    
    UILabel *vipLab = [[UILabel alloc] init];
    [bangView addSubview:vipLab];
    [vipLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(moneyLab.mas_bottom).with.offset(40);
        make.centerX.equalTo(bangView);
        
    }];
    vipLab.text = @"VIP1会员: 38";
    vipLab.textColor = getColor(@"818181");
    vipLab.font = [UIFont systemFontOfSize:17];

    UIButton *gouMaiBtn = [[UIButton alloc] init];
    [bangView addSubview:gouMaiBtn];
    [gouMaiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(vipLab.mas_bottom).with.offset(40);
        make.centerX.equalTo(bangView);
        make.width.offset(120);
        make.height.offset(30);
    }];
    [gouMaiBtn setBackgroundImage:[UIImage imageNamed:@"bg_top"] forState:UIControlStateNormal];
    [gouMaiBtn setTitle:@"购买" forState:UIControlStateNormal];
    [gouMaiBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    gouMaiBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    gouMaiBtn.layer.cornerRadius = 15;
    gouMaiBtn.layer.masksToBounds = YES;
    
    
    UIButton *xButton = [[UIButton alloc] init];
    [xButton setBackgroundImage:[UIImage imageNamed:@"icon_x"] forState:UIControlStateNormal];
    [bangView addSubview:xButton];
    [xButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bangView);
        make.right.equalTo(bangView);
    }];
    [xButton addTarget:self action:@selector(dismissVIPView) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    
    
}

- (void)dismissVIPView{
    
    [vipView removeFromSuperview];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
